const jwt = require('jsonwebtoken')

Token = {
  en(str){
    //加密
    let tokenKey = jwt.sign(str,'XIAxing')
    return tokenKey
  },
  de(token){
    //解密
    try{
      let tokenKey = jwt.verify(token,'XIAxing')
      return{
        status:'success',
        tokenKey
      }
    } catch{
      return{
        status:'faile'
      }
    }
  }
}

module.exports = Token